from selenium.webdriver.common.by import By
import time

from Week.Base.base import Base


class Page(Base):
    # 输入姓名
    name_loc = (By.XPATH, "/html/body/div[1]/div/section/section/main/div[1]/div[2]/div[1]/div/input")

    def login_name(self, test):
        self.send_keys(self.name_loc, test)

    # 输入密码
    pwd_loc = (By.XPATH,"/html/body/div[1]/div/section/section/main/div[1]/div[2]/div[2]/div/input")

    def login_pwd(self, test):
        self.send_keys(self.pwd_loc, test)

    # 点击登陆
    deng_loc = (By.XPATH, '/html/body/div[1]/div/section/section/main/div[1]/div[2]/button[2]')

    def login_deng(self):
        self.click(self.deng_loc)

    # 确认登陆
    qve_log = (By.XPATH,'/html/body/div[1]/div/section/section/main/div[2]/div/div/div/div[2]/button[2]')

    def login_qve(self):
        self.click(self.qve_log)

    # 执行脚本
    def login_test(self,name,pwd):
        self.open_url("http://localhost:8080/loginn")
        print("打开登陆网站")
        self.login_name(name)
        print("输入名字")
        self.login_pwd(pwd)
        print("输入密码")
        self.login_deng()
        print("点击登录")
        self.login_qve()
        print("确认登陆")
        time.sleep(3)

